package com.woniu.controller;

import com.woniu.pojo.DirectOrderDetails;
import com.woniu.pojo.DirectOrders;
import com.woniu.service.DirectOrderDetailsService;
import com.woniu.service.DirectOrdersService;
import com.woniu.until.ResponseData;
import com.woniu.until.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/directOrder")
public class DirectOrderController {

    @Autowired
    private DirectOrdersService ordersService;

    @Autowired
    private DirectOrderDetailsService directOrderDetailsService;

    @PostMapping("/saveDirectOrder")
    public ResultData saveDirectOrder(@RequestBody DirectOrders directOrders){
        ordersService.save(directOrders);
        return new ResultData<>(200,"ok",null);
    }

    @GetMapping("/getDirectOrders")
    public ResponseData<?>getDirectOrders(){
        List<DirectOrderDetails> list = directOrderDetailsService.list();
        return new ResponseData<>().ok(list);
    }
}
